<template>
  <a-config-provider :locale="locale">
    <!--路由管道标签，任何符合某一路由(route)信息的组件都会在这个标签内展示出来 -->
    <router-view></router-view>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import store from './store';
import ConfigApi from './api/ConfigApi.js'

export default {
  name: 'App',
  data() {
    return {
      locale: zhCN,
      isMobile: false,
    }
  },
  created() {
    store.restoreTokenCookiedAction()
    store.isMobile(this.checkMobile())
    // this.getAppVersion()
  },
  methods: {
    // 从服务器获取版本号
    getAppVersion() {
      ConfigApi.get().then(response=>{
        if (response.data.code === 1) {
          store.setAppVersion(response.data.data.version)
        } else {
          this.$message.error(`数据加载失败：${response.data.message}`)
        }
      }).catch((error)=>{
        this.$message.error(`数据加载失败：${error.message}`)
      })
    },
    checkMobile() {
      let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
      return flag ? true : false;
    }
  }
}
</script>